<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<title>活动详情</title>
<link href="<%=path%>/favicon.ico" rel="shortcut icon">

<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/public.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/activity.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/custom.css" />
<link rel="stylesheet" type="text/css" href="<%=path%>/css/marketing/style_list.css" />  
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/marketing.css" />

<link href="<%=path%>/hplus/css/bootstrap.min14ed.css?v=3.3.6"
	rel="stylesheet">
<link href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"
	rel="stylesheet">
<link href="<%=path%>/hplus/css/plugins/iCheck/custom.css"
	rel="stylesheet">
<link href="<%=path%>/hplus/css/plugins/footable/footable.core.css"
	rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/hplus/css/plugins/dataTables/css/jquery.dataTables.min.css" />
<link href="<%=path%>/hplus/css/animate.min.css" rel="stylesheet">
<link href="<%=path%>/hplus/css/style.min862f.css?v=4.1.0"
	rel="stylesheet">
<link href="<%=path%>/hplus/css/plugins/clockpicker/clockpicker.css"
	rel="stylesheet">
<link href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css"
	rel="stylesheet">
 <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css">
 <style type="text/css">
 .table tbody tr td{
 	padding:0;
 }
 tbody tr td ol{
 	margin-bottom:0;
 }
  tbody tr td ol li{
	height: 50px;
	line-height: 50px;
	border-bottom: 1px solid #eee;
}
tbody tr td .s_none_line li{
	border-bottom: none;
}
 tbody tr td ol li:last-child{
	border-bottom: none;
}

tbody tr td ul li{
	height: 37.5px;
	line-height: 37.5px;
}

 tbody tr td .k_ol li{
	line-height: 18px;
	border-bottom: none;
	padding-top: 6px;
}
 
 
 </style>
</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight">
	<div class="container-fluid">
		
		<div class="row">
			<div class="col-md-12">
				<table class="table table-bordered table-hover">
					<thead>
						<tr>
							<th>活动概览</th>
							<th>统计值</th>
							<th>状态</th>
							<th>分享<br />渠道
							</th>
							<th>打开数</th>
							<th>提交表<br />单数
							</th>
							<th>转化比例</th>
							<th>一次人脉</th>
							<th>二次人脉</th>
							<th>累计核<br />销金额
							</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody id="activity_table">
					    <tr>
					        <td><dl class="k_img_box"><dt class="col-sm-3"><img id="activityPic" style="width:75px;height:100px" src="http://oss.300.cn/cook_test:cecook-test/3e5f7306-5526-43f4-9867-05c661efccfb"></dt><dd class="col-sm-8"><h3 id="activityName" style="margin-top:9px; margin-left: 9px;"></h3><p id="receiveNum" style="margin-left: 9px;">领取数:0/总数:0</p><p id="validTime" style="margin-left: 9px;margin-top: 4px;"></p></dd></dl></td>
					        <td id="activityRatio">转化率:0.0%</td>
					        <td id="activity_state">正常</td>
					        <td><ol><li>微博</li><li>微信</li><li>QQ</li><li>其他</li></ol></td>
					        <td><ol><li id="weiboOpen">0</li><li id="weixinOpen">0</li><li id="qqOpen">0</li><li id="otherOpen">0</li></ol></td>
					        <td><ol><li id="weiboReceive">0</li><li id="weixinReceive">0</li><li id="qqReceive">0</li><li id=otherReceive>0</li></ol></td>
					        <td><ol><li id="weiboRatio">0%</li><li id="weixinRatio">0%</li><li id="qqRatio">0%</li><li id="otherRatio">0%</li></ol></td>
					        <td><ol class="s_none_line"><li><span id="onceClick">点击人数:0</span></li><li><span id="onceReceive">领券人数:0</span></li><li><span id="onceVerify">核销人数:0</span></li><li><span id="onceTransmit">转发次数:0</span></li></ol></td>
					        <td><ol class="s_none_line"><li><span id="twiceClick">点击人数:0</span></li><li><span id="twiceReceive">领券人数:0</span></li><li><span id="twiceVerify">核销人数:0</span></li><li><span id="twiceTransmit">转发次数:0</span></li></ol></td>
					        <td id="verifyAmmount">0</td>
					        <td>
						        <shiro:hasPermission name="markting_activity_h5:start"><a href="javascript:;" class="manageActivity"><font color="#1ab394" id="activityStatusTip">停用</font></a></shiro:hasPermission><br>
						        <shiro:hasPermission name="markting_activity_h5:create"><a href="javascript:;" class="copyActivity"><font color="#1ab394">复制</font></a></shiro:hasPermission><br>
						        <shiro:hasPermission name="markting_activity_h5:update"><a href="javascript:;" class="editActivity"><font color="#1ab394">编辑</font></a></shiro:hasPermission><br>
						        <shiro:hasPermission name="markting_activity_h5:delete"><a href="javascript:;" class="deleteActivity"><font color="#1ab394">删除</font></a></shiro:hasPermission><br>
						        <a href="javascript:;"class="shareActivity"><font color="#1ab394">分享</font></a><br>
						        <a href="javascript:intentReport();"><font color="#1ab394">报告</font></a>
					        </td>
					    </tr>
					
					
					</tbody>
				</table>
				
				
				<div class="col-md-12" style="margin-top:20px;margin-bottom:20px;margin-left:-30px">
					<form class="form-horizontal">
		                <div class="form-group col-sm-4" id="data_5">
		                    <div class="input-daterange input-group" id="datepicker" style="padding-left:15px">
		                        <input id="start_time" type="text" class="input-sm form-control" style="background-color: white;" name="start" readonly="readonly" onchange="javascript:timeChange();">
		                        <span class="input-group-addon">到</span>
		                        <input id="end_time" type="text" class="input-sm form-control" style="background-color: white;" name="end" readonly="readonly" onchange="javascript:timeChange();">
		                    </div>
		                </div>   
		                           
		                <div class="col-sm-8">
		                    <button onclick="javascript:exportDatas();" class="btn btn-primary pull-right" type="button">导出表单</button>
		                </div>
		            </form>
				</div>
				<div class=tabs-container>
					<ul class="nav nav-tabs" id="J_stitle">
					    <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">新线索</a></li>
					    <li class=""><a data-toggle="tab" href="#tab-1" aria-expanded="true">浏览用户</a></li>
						<li class=""><a data-toggle="tab" href="#tab-1" aria-expanded="true">填表用户</a></li>
						<li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="true">核销表单</a></li>
					</ul>
					
					<div class="tab-content">
						<div id="tab-1" class="tab-pane  active">
							<div class="ibox float-e-margins">
			                    <div class="table-responsive">
			                         <table class="table-striped table-bordered table-hover" id="newClueTable" >
			                            <thead>
			                                <tr>
			                                    <th>姓名</th>
												<th>电话</th>
												<th>分享来源</th>
												<th>所属门店</th>
												<th>营销渠道</th>
												<th>时间</th>
			                                </tr>
			                            </thead>
			                            <tbody>
			                            </tbody>
			                        </table>
			                    </div>                 
				            </div>
						</div>
						
						<div id="tab-2" class="tab-pane">
							<div class="ibox float-e-margins">
			                    <div class="table-responsive">
			                         <table class="table-striped table-bordered table-hover" id="verifyTable" >
			                            <thead>
			                                <tr>
			                                    <th>姓名</th>
												<th>电话</th>
												<th>分享来源</th>
												<th>性别</th>
												<th>营销渠道</th>
												<th>核销券名</th>
												<th>核销时间</th>
			                                </tr>
			                            </thead>
			                            <tbody>
			                            </tbody>
			                        </table>
			                    </div>                 
				            </div>
						</div>
						
					</div>
				</div>			
			 </div>
		</div>
	</div>
</div>
<div hidden="" class="modal inmodal fade" id="share_modal" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">扫一扫立刻分享</h4>
            </div>
            <div class="modal-body text-center">
               <div id="qrcode"></div>
               <div style="margin-top:15px;margin-left:10px;margin-bottom:20px">
                   <h5 style="float: left;width:15%;margin-top:10px">链接</h5>
                   <input id="shortUrl" type="text" class="input form-control" style="float: left;width:55%;" readonly="readonly">
                   <button id="btnCopy" class="btn btn-primary" type="button" style="float: left;width:25%;margin-left:5%" data-clipboard-action="copy" data-clipboard-target="#shortUrl">复制链接</button>
               </div>
                <div style="margin-top:10px;">
                   <button class="btn btn-primary" type="button" style="width:25%;margin-right: 5%;margin-top: 15px;" onclick="javascript:intentSocialSms();">群发短信</button>
               </div>
            </div>
        </div>
    </div>
</div>   
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script type="text/javascript" src="<%=path%>/js/marketing/custom.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/dialog-plus.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/lengthlimit.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
	
    <script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="<%=path%>/hplus/js/content.min.js?v=1.0.0"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/dialog.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
	<script type="text/javascript"
		src="<%=path%>/hplus/js/plugins/dataTables/jquery.dataTables.min.js"></script>
	<script src="<%=path%>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=path%>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=path%>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=path%>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=path%>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=path%>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=path%>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
    <script src="<%=path%>/hplus/js/plugins/cropper/cropper.min.js"></script>
    <script src="<%=path%>/hplus/js/demo/form-advanced-demo.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.js"></script>
	<script type="text/javascript">
	   $.fn.dataTable.ext.errMode = 'none';
	   var activity_id;
	   var access_token=$.cookie('access_token');
	   var cid=$.cookie('cid');
	   var uid=$.cookie('uid');
	   var user_name = $.cookie('user_name');
	   var path = "<%=path%>";
	   var startIndex = 0;
	   var pageSize = 10;
	   var currentPage = 1;
	   var pageCount = 0;
	   var index=3;
	   var listIndex = 1;
	   var type;
	   var manage_activity_id;
	   var manage_customer_id;
	   var activity_type;
	   var action_type;
	   var startTime="";
	   var endTime="";
	   	var tabType="newClue";
	   //新线索表
	   var newClueTable;
	   var verifyTable=null;
	   var loadCompleteFlag=false;
	   var webUrl="";
	   var activityStatus;
	   var memberDetailDialog = null;
	   var activityId=0;
	   var activityName="";
	   var newFlag=1;
	   
       $(function(){
        	//获取活动id
        	activity_id=getQueryString("activity_id");
        	activity_type=getQueryString("type");
        	if(activity_type=="0"){
        		action_type="3";
        	}else if(activity_type=="1"){
        		action_type="2";
        	}
        	initView(activity_id);
        	initDate();
        	newClueTable=newClueTable();
		});
       
      function initDate(){
      	var myDate = new Date();
    	//获取当前年
    	var year=myDate.getFullYear();
    	//获取当前月
    	var month=myDate.getMonth()+1;
    	var beforeMonth=myDate.getMonth();
    	var beforeYear=year;
    	//获取当前日
    	var day=myDate.getDate(); 
    	if(month>12){
    		year=year+1;
    		month=1;
    	}
    	if(beforeMonth==0){
    		beforeMonth=12;
    		beforeYear=beforeYear-1;
    	}
    	
    	$("#end_time").val(year+"-"+month+"-"+day);
    	$("#end_time").attr("value",year+"-"+month+"-"+day);
    	$("#start_time").attr("value",beforeYear+"-"+beforeMonth+"-"+day);
    	$("#start_time").val(beforeYear+"-"+beforeMonth+"-"+day);
    	
    	$("#start_time").datepicker("setDate",beforeYear+"-"+beforeMonth+"-"+day);
    	$("#end_time").datepicker("setDate",year+"-"+month+"-"+day); 
    	
    	
    	startTime=$('#start_time').val();
    	endTime=$('#end_time').val();
      }
       
		$('#J_stitle li').click(
				function() {
					$(this).addClass('s_all_on').siblings().removeClass();
				    index = $(this).index();
					$('.s_table>div').removeClass('s_table_sur').eq(index)
							.addClass('s_table_sur');
					switch(index)
					{
					case 0:
						tabType="newClue";
						newClue_dataTableReload();
					   break;
                    case 1:
                    	tabType="browse";
                    	newClue_dataTableReload();
					    break;
					case 2:
						tabType="submit";
						newClue_dataTableReload();
					    break;
					case 3:
						tabType="verify";
						if(verifyTable==null){
							verifyTable=couponVerifyTable();
						}
					    break;
					case 4:
					    break;
					
					default:
					/* 	writeOffList(activity_id); */
					}
					
				});
		
		
		//点击创建活动跳转
		$('#intent_crate_activity').click(function(){
        	  window.location.href="<%=path%>/view/ui/chooseActivityTemplate";
      	  });



		
	    $('.s_cancel,.issue_delect span').click(function(){
	         $('.s_popup_delect,.issue_delect').hide();
	     });
		
	     $('.s_cancel1,.issue_delect1 span').click(function(){
	         $('.s_popup_delect1,.issue_delect1').hide();
	     });
		
		 // 启用或者停用操作
          $(document).on('click', '.manageActivity', function() {
				if(activityStatus==1){
					suspendDialog();
				}else{
					activateActivity();
				}
			});
          //复制活动
          $(document).on('click', '.copyActivity', function() {
        	  if(type=="sys"){
        		  window.location.href = "<%=path%>/api/bm/ui/createActivity2?type=copy&activity_id="+activity_id;
        	  }else if(type=="defined_pic"){
        		  window.location.href = "<%=path%>/view/ui/photoAlbum?type=activity_copy&activity_id="+activity_id;
        	  }else if(type=="defined_text"){
        		  window.location.href = "<%=path%>/view/ui/createModel?type=activity_copy&activity_id="+activity_id;
        	  }else if(type=="sys_invitation"){
        		  window.location.href = "<%=path%>/api/bm/ui/invitation01?type=activity_copy&activity_id="+activity_id;
        	  }
				
			});
          //编辑活动
          $(document).on('click', '.editActivity', function() {
        	  if(type=="sys"){
        		  window.location.href = "<%=path%>/api/bm/ui/createActivity2?type=edit&activity_id="+activity_id;
        	  }else if(type=="defined_pic"){
        		  window.location.href = "<%=path%>/view/ui/photoAlbum?type=activity&activity_id="+activity_id;
        	  }else if(type=="defined_text"){
        		  window.location.href = "<%=path%>/view/ui/createModel?type=activity&activity_id="+activity_id;
        	  }else if(type=="sys_invitation"){
        		  window.location.href = "<%=path%>/api/bm/ui/invitation01?type=edit&activity_id="+activity_id;
        	  }
			});
          //删除活动
          $(document).on('click', '.deleteActivity', function() {
			  deletedDialog();
			});
          //分享活动
          $(document).on('click', '.shareActivity', function() {
        	  if(activityStatus==1){
        		  shareActivity();
        	  }else if(activityStatus==0){
        		  errorDialog('活动未启用，不能分享！');
        	  }else{
        		  errorDialog('活动未编辑完成，不能分享！');
        	  }
		  });
          $('.J_x_box').click(function () {
              $('.x_popup').show();
             $('.issue').show(); 
         });
         $('.x_popup .issue span').click(function () {
              $('.x_popup').hide();
             $('.issue').hide(); 
         });
          
		
		//初始化  获取活动详情
		function initView(activity_id) {
			
			var url="<%=path%>/activity/ajaxActivityStatisticsDetail";
			$.post(url, {
				"id" : activity_id,
			}, function(data) {
				type=data.data.activityType;
				if (data.status == 200) {
					activityhtml(data.data);
				} else {

				}
			});
		 }
        
		
		
		//激活
        function activateActivity() {
			var url = "${pageContext.request.contextPath}/activity/ajaxActivateActivity";
			var manageId="#manageId"+activity_id;
			var shareManageId="#shareManageId"+activity_id;
			$.post(url, {
				"uid" : uid,
				"id" : activity_id,
			}, function(data) {
				if (data.status == 200) {
					successDialog("启用成功");
					activityStatus=1;
					$('.manageActivity').html('<font color="#1ab394" id="activityStatusTip">停用</font>');
					$('#activity_state').html("<p style='color:black;'>正常</p>");
				} else {
					errorDialog("启用失败");
				}
			});
		}
        //停用
		function suspendActivity() {
			var url = "${pageContext.request.contextPath}/activity/ajaxActivitySuspend";
			$.post(url, {
				"uid" : uid,
				"activityId" : activity_id,
			}, function(data) {
				
				if (data.status == 200) {
					activityStatus=0;
					successDialog("停用成功");
					$('.manageActivity').html('<font color="#ff7469" id="activityStatusTip">启用</font>');
					$('#activity_state').html("<p style='color:red'>停用</p>");
				} else {
					errorDialog("停用失败");
				}
			});
		}
        //删除
        function deleteActivity() {
			var url = "${pageContext.request.contextPath}/activity/ajaxActivityDelete";
			
			$.post(url, {
				"id" : activity_id,
			}, function(data) {
				if (data.status == 200) {
					successDialog("删除成功");
					$(lineId).remove();
				} else {
					errorDialog("删除失败");
				}
			});
		}
		
	      function activityhtml(result){
	    	  activityId=result.id;
	    	  activityName=result.name;
	    	  var activityPic=result.pic;
	    	 // var receiveCouponNum=parseInt(result.receiveCoupon)+parseInt(result.twiceReceive);
	    	  
	    	  $('#activityPic').attr('src',activityPic);
	    	  $('#activityName').html(result.name);
	    	  $('#receiveNum').html('领取数:'+result.receiveCouponNum+'/总数:' + result.couponNumber);
	    	  if(StringEmpty(result.end_time)){
	    		  $('#validTime').html("有效期至"+result.endTime);
	    	  }
	    	  $('#activityRatio').html('转化率:'+(result.ratio!=undefined?result.ratio:"0")+'%');
	    	  
	    	  $("#weiboOpen").html(result.weiboNum );
	    	  $("#weixinOpen").html(result.weixinNum);
	    	  $("#qqOpen").html(result.qqNum);
	    	  $("#otherOpen").html(result.otherClick);
	    	  
	    	  $("#weiboReceive").html(result.submitWeiboNum );
	    	  $("#weixinReceive").html(result.submitWeixinNum);
	    	  $("#qqReceive").html(result.submitQqNum);
	    	  $("#otherReceive").html(result.otherSubmit);
	    	  
	    	  $("#weiboRatio").html(result.weiboRatio+"%");
	    	  $("#weixinRatio").html(result.weixinRatio+"%");
	    	  $("#qqRatio").html(result.qqRatio+"%");
	    	  $("#otherRatio").html(result.otherRatio+"%");
	    	  
	    	  $("#onceClick").html("点击人数:"+result.clickNum);
	    	  $("#onceReceive").html("领取人数:"+result.onceReceiveNum);
	    	  $("#onceVerify").html("核销人数:"+result.varicationNum);
	    	  $("#onceTransmit").html("转发次数:"+result.transmitNum);
	    	  
	    	  $("#twiceClick").html("点击人数:"+result.twiceClick);
	    	  $("#twiceReceive").html("领取人数:"+result.twiceReceive);
	    	  $("#twiceVerify").html("核销人数:"+result.twiceVarication);
	    	  $("#twiceTransmit").html("转发次数:"+result.twiceTransmit);
	    	  $("#verifyAmmount").html(result.activityAmount);
	    	  activityStatus=result.status;
	    	  webUrl=result.webUrl;
	    	  if(result.status == 1){
	    		  $('#activity_state').html("正常");
	    		  $('.manageActivity').html('<font color="#1ab394" id="activityStatusTip">停用</font>');
	    	  }else{
	    		  $('#activity_state').html("<font color='#ff7469'>停用</font>");
	    		  $('.manageActivity').html('<font color="#ff7469" id="activityStatusTip">启用</font>');
	    	  }
			  imageLoadError();
			}
	     
	        /**
	         *	设置列名，对应后台
	         */
	        function newClue_columns(){
	        	var jsonArr = [
	        		{"data":"customerName"},
	        		{"data":"customerPhone"},
	        		{"data":"shareSource"},
	        		{"data":"storeName"},
	        		{"data":"socialChannel"},
	        		{"data":"createTime"},
	        	];
	        	return jsonArr;
	        }
	        function newClue_AjaxUrl(){
	        	return path+"/activity/ajaxListSubmitByWhere";;
	        }
	        function newClue_dataTableReload(){
	        	var requestUrl="";
	        	switch (tabType) {
				case "newClue":
					requestUrl=path+"/activity/ajaxListSubmitByWhere";
					newFlag=1;
					break;
				case "browse":
					requestUrl=path+"/activity/ajaxBrowseListByActivityId";
					break;
				case "submit":
				    requestUrl=path+"/activity/ajaxListSubmitByWhere";
				    newFlag=null;
					break;
				default:
					break;
				}
	        	newClueTable.ajax.url(requestUrl).load();
	        }
	        function newClueTable(){
	        	return $('#newClueTable').DataTable({
	        		processing: true,
	        		ordering: false,
	        		searching: false,
	        		info: true,
	        		autoWidth: true,
	        		lengthChange: false,
	        	    language: {
	        	    	emptyTable: '暂无数据',
	        	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
	        			infoEmpty: '没有数据',
	        			lengthMenu: '每页显示 _MENU_ 条记录',
	        			loadingRecords: '正在加载数据....',
	        			processing: '正在处理数据....',
	        			zeroRecords: '没有找到匹配的记录',
	        			paginate: {
	        				first: '首页',
	        				previous: '前页',
	        				next: '后页',
	        				last: '尾页'
	        			}
	        	    },
	        		pageLength: 10,
	        	    pagingType: 'full_numbers',
	        	    columnDefs: [{
	       	         'targets' : [],    //除第六，第七两列外，都默认不排序
	    	         'orderable' : false
	                 },{
	                	 render: function(data, type, full) {
	                		 return '<a href="javascript:func_showMemberDetailDialog(\''+full.customerId+'\');"><font color="#1ab394">'+data+'</font></a>';
	                     },
	         			targets: 0
	                 }],
	        	    columns: newClue_columns(),
	        	    serverSide: true,
	        	    ajax: {
	        	    	contentType: 'application/json',
	        	    	type: 'POST',
	        	    	url: newClue_AjaxUrl(),
	        	    	data: function(d){
	        	    		d.startTime=startTime;
	        	    		d.endTime=endTime;
	        	    		d.activityId=activity_id;
	        	    		d.listIndex = 1;
	        	    		d.newFlag=newFlag;
	        				return JSON.stringify(d);
	        			}
	        		} ,
	        	    "initComplete": function(settings, json) {
	        	    	loadCompleteFlag=true;
	        	    	var info=newClueTable.page.info(); 
	                    if(json.error_code=="20028"){
	                    	loginDialog();
	                    }else{
	                    	/* if(info.recordsTotal<1){
	                    		createDialog()
	                    	} */
	                    }     	    	
	        	    }
	        	});
	        	
	        }
	     
	        
	        
	        
	        function verify_columns(){
	        	var jsonArr = [
	        		{"data":"customerName"},
	        		{"data":"customerPhone"},
	        		{"data":"shareSource"},
	        		{"data":"gender"},
	        		{"data":"socialChannel"},
	        		{"data":"couponName"},
	        		{"data":"createTime"},
	        	];
	        	return jsonArr;
	        }
	        function verify_AjaxUrl(){
	        	return path+"/coupon/ajaxListVerifyByActivityId";;
	        }
	        function verify_dataTableReload(){
	        	verifyTable.ajax.reload();
	        }
	        function couponVerifyTable(){
	        	return $('#verifyTable').DataTable({
	        		processing: true,
	        		ordering: false,
	        		searching: false,
	        		info: true,
	        		autoWidth: true,
	        		lengthChange: false,
	        	    language: {
	        	    	emptyTable: '暂无数据',
	        	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
	        			infoEmpty: '没有数据',
	        			lengthMenu: '每页显示 _MENU_ 条记录',
	        			loadingRecords: '正在加载数据....',
	        			processing: '正在处理数据....',
	        			zeroRecords: '没有找到匹配的记录',
	        			paginate: {
	        				first: '首页',
	        				previous: '前页',
	        				next: '后页',
	        				last: '尾页'
	        			}
	        	    },
	        		pageLength: 10,
	        	    pagingType: 'full_numbers',
	        	    columnDefs: [{
	       	         'targets' : [],    
	    	         'orderable' : false
	                 },{
	                	 render: function(data, type, full) {
	                		 return '<a href="javascript:func_showMemberDetailDialog(\''+full.customerId+'\');"><font color="#1ab394">'+data+'</font></a>';
	                     },
	         			targets: 0
	                 }],
	        	    columns: verify_columns(),
	        	    serverSide: true,
	        	    ajax: {
	        	    	contentType: 'application/json',
	        	    	type: 'POST',
	        	    	url: verify_AjaxUrl(),
	        	    	data: function(d){
	        	    		d.startTime=startTime;
	        	    		d.endTime=endTime;
	        	    		d.activityId=activity_id;
	        	    		d.listIndex = 2;
	        				return JSON.stringify(d);
	        			}
	        		} ,
	        	    "initComplete": function(settings, json) {
	        	    	var info=newClueTable.page.info(); 
	                    if(json.error_code=="20028"){
	                    	loginDialog();
	                    }else{
	                    	
	                    }     	    	
	        	    }
	        	});
	        	
	        }
	        
	        
	      function timeChange(){
	    	    if(!loadCompleteFlag){
	    		   return;
	    	    }
		    	startTime=$('#start_time').val();
		      	endTime=$('#end_time').val();
		      	switch (tabType) {
				case "newClue":
					newClue_dataTableReload();
					break;
				case "browse":
					newClue_dataTableReload();
					break;
				case "submit":
					newClue_dataTableReload();
					break;
				case "verify":
					verify_dataTableReload();
					break;
				default:
					newClue_dataTableReload();
					break;
		         }
	      }
	        
	      $('#bm_qux').click(function(){
	    	  $('.s_popup,.issue').hide(); 
	      });
	      $('.issue > span').click(function(){
	          $('.s_popup,.issue').hide();
	      });
       $('.s_finish').click(function(){
       	//  window.location.reload();
       	  var ssid = '#writeOffLine'+coupon_code;
       	  $('.s_popup1,.issue1').hide();
       	  $('.s_popup,.issue').hide();
       	  $(ssid).remove();
       });
       
     //判断字符串是否为空
		function StringEmpty(content) {
			if (content == undefined || content == "" || content == null) {
				return false;
			} else {
				return true;
			}
		}
		function deletedDialog(){
			swal({
				  title: '您确定要删除此活动吗?',
				  text: "删除后将无法恢复，请谨慎操作！",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#d33',
				  cancelButtonColor: '#3085d6',
				  confirmButtonText: '删除',
				  cancelButtonText:'取消'
				}).then(function () {
					deleteActivity();
				})
		}
		
		function suspendDialog(){
			swal({
				  title: '您确定要停用此活动吗?',
				  text: "活动停用后用户将无法参加此活动！",
				  type: 'warning',
				  showCancelButton: true,
				  confirmButtonColor: '#d33',
				  cancelButtonColor: '#3085d6',
				  confirmButtonText: '停用',
				  cancelButtonText:'取消'
				}).then(function () {
					suspendActivity();
				})
		}
		function exportDatas(){
			var paramObj=new Object();
			startTime=$('#start_time').val();
	      	endTime=$('#end_time').val();
	      	paramObj.startTime=startTime;
	      	paramObj.endTime=endTime;
	      	paramObj.activityId=activity_id;
	      	paramObj.newFlag=newFlag;
			var paramJson=JSON.stringify(paramObj);
			switch (tabType) {
			case "newClue":
				window.location.href=path+"/activity/exportSubmitByWhere?listIndex=1&paramJson="+encodeURI(paramJson);
				break;
			case "browse":
				window.location.href=path+"/activity/exportBrowseListByActivityId?cid="+cid+"&uid="+uid+"&access_token="+access_token+"&paramJson="+encodeURI(paramJson);
				break;
			case "submit":
				window.location.href=path+"/activity/exportSubmitByWhere?listIndex=2&paramJson="+encodeURI(paramJson);

				break;
			case "verify":
				window.location.href=path+"/coupon/exportVerifyByActivityId?paramJson="+encodeURI(paramJson);
				break;
			default:
				window.location.href=path+"/activity/exportSubmitByWhere?listIndex=1&paramJson="+encodeURI(paramJson);
				break;
	         }
        }
		
		
		function shareActivity(){
        	var url="<%=path%>/activity/ajaxLongUrlToShort";
    		$.post(url, {
    			"longUrl" : webUrl,
                "uid": uid
            }, function(data) {
    			if (data.status == 200) {
    				var shortUrl=data.data;
    				$('#qrcode').html("");
    				$("#shortUrl").val(shortUrl);
               	    jQuery('#qrcode').qrcode(shortUrl);
               	    $('#share_modal').modal('show');
    			}else if(data.error_code=="20028"){
    				loginDialog();
	        	}else{
	        		errorDialog(data.message);
	        	}
    		});
        }
		//复制短链
		$(document).ready(function(){    
			var clipboard = new ClipboardJS('#btnCopy');
			   clipboard.on('success', function(e) {  
				   $('#share_modal').modal('hide');
				   successDialog("复制成功");
			   });  
			   clipboard.on('error', function(e) {  
				   $('#share_modal').modal('hide');
				   successDialog("复制失败！请手动复制");
			   });  
		}) 
		//跳转到群发短信
		function intentSocialSms(){
			window.location.href="<%=path%>/view/sms/choseSendObject?type=create&activityId="+activity_id;
		}
		//会员详情弹出框
		function func_showMemberDetailDialog(memberId) {
	        memberDetailDialog = dialog({
	            id: "memberDetailDialog",
	            fixed: true,
	            width: 900,
	            height: 400,
	            title: '会员详情',
	            url: path + "/view/member/member/memberDetail?memberId=" + memberId,
	            cancel: true,
	            cancelValue: "关闭"
	        });
	        memberDetailDialog.showModal();
	        $("iframe[name='memberDetailDialog']:visible").attr("scrolling", "auto").css("overflow-x", "hidden").css("overflow-y", "auto");
	     }
		
		function intentReport(){
			var reportUrl="<%=path%>/activity/detailReport?activityId="+activityId+"&activityName="+activityName;
			reportUrl=encodeURI(reportUrl);
			window.location.href=reportUrl;
		}
	</script>
	
</body>
</html>